﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电子商务购物平台</title>
    @*<link href="~/Content/css/framework-font.css" rel="stylesheet" />
        <link href="~/Content/css/framework-login.css" rel="stylesheet" />*@
    <link href="~/Content/css/mylogin.css" rel="stylesheet" />
    <script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
    <script src="~/Content/js/cookie/jquery.cookie.js"></script>
    <script src="~/Content/js/md5/jquery.md5.js"></script>
    <script type="text/javascript">
            (function ($) {
                $.login = {
                    formMessage: function (msg) {
                        $('.login_tips').find('.tips_msg').remove();
                        $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
                    },
                    loginClick: function () {
                        var $username = $("#txt_account");
                        var $password = $("#txt_password");
                        var $code = $("#txt_code");
                        if ($username.val() == "") {
                            $username.focus();
                            $.login.formMessage('请输入用户名');
                            return false;
                        } else if ($password.val() == "") {
                            $password.focus();
                            $.login.formMessage('请输入登录密码。');
                            return false;
                        } else if ($code.val() == "") {
                            $code.focus();
                            $.login.formMessage('请输入验证码。');
                            return false;
                        } else {
                            $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
                            $.ajax({
                                url: '@Url.Content("~/Login/CheckLogin")',
                                data: { username: $.trim($username.val()), password: $.md5($.trim($password.val())), code: $.trim($code.val()) },
                                type: "post",
                                dataType: "json",
                                success: function (data) {
                                    if (data.state == "success") {
                                        $.login.formMessage('登录成功，正在跳转...');
                                        //$("#login_button").find('span').html("登录成功，正在跳转...");
                                        window.setTimeout(function () {
                                            window.location.href = '@Url.Content("~/Home/Index")';
                                        }, 500);
                                    } else {
                                        $("#login_button").removeAttr('disabled').find('span').html("登录");
                                        $("#switchCode").trigger("click");
                                        $code.val('');
                                        $.login.formMessage(data.message);
                                    }
                                }
                            });
                        }
                    },
                    init: function () {
                        $('.wrapper').height($(window).height());
                        $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                        $(window).resize(function (e) {
                            $('.wrapper').height($(window).height());
                            $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                        });
                        $("#switchCode").click(function () {
                            $("#imgcode").attr("src", '@Url.Content("~/Login/GetAuthCode?time=")' + Math.random());
                        });
                        var login_error = top.$.cookie('nfine_login_error');
                        if (login_error != null) {
                            switch (login_error) {
                                case "overdue":
                                    $.login.formMessage("系统登录已超时,请重新登录");
                                    break;
                                case "OnLine":
                                    $.login.formMessage("您的帐号已在其它地方登录,请重新登录");
                                    break;
                                case "-1":
                                    $.login.formMessage("系统未知错误,请重新登录");
                                    break;
                            }
                            top.$.cookie('nfine_login_error', '', { path: '@Url.Content("~/")', expires: -1 });
                        }
                        $("#login_button").click(function () {
                            $.login.loginClick();
                        });
                        document.onkeydown = function (e) {
                            if (!e) e = window.event;
                            if ((e.keyCode || e.which) == 13) {
                                document.getElementById("login_button").focus();
                                document.getElementById("login_button").click();
                            }
                        }
                    }
                };
                $(function () {
                    $.login.init();
                });
            })(jQuery);
    </script>
</head>
<body class="login_bj">
    <div class="head">
        <a href="#">
            <img class="head_img" src="~/Content/img/购物平台.png" />
        </a>
    </div>
    <div class="content">
        <div class="content_left">
            <p>登录</p>
            <form>
                <input id="txt_account" type="text" class="input_text" placeholder="用户名">
                <input id="txt_password" type="password" class="input_text" placeholder="密码">
                <input id="login_button" type="button" class="input_button" value="登 录">
                <div class="login_tips"></div>
            </form>
        </div>
        @*<div class="content_right">
                <p>电子商务购物平台</p>
            </div>*@

    </div>
</body>
</html>
